//
//  JGRegistController.m
//  JGRider
//
//  Created by 单启志 on 2018/3/2.
//  Copyright © 2018年 ffq. All rights reserved.
//

#import "JGRegistController.h"
#import "JGRegistContentView.h"
#import "JGRegistApi.h"
#import "JGValidateCodeApi.h"

#import "JGCityCodeHelper.h"
@interface JGRegistController ()<JGRegistContentViewDelegate,YTKChainRequestDelegate>
@property(nonatomic,strong)MBProgressHUD *hud;
@property(nonatomic,strong)JGRegistContentView *contentView;
@end

@implementation JGRegistController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configSubViews];
}

-(void)configSubViews{

    [self.view addSubview:self.contentView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - contentview delegate
-(void)contentViewValidateCodeEvent{
    
}
-(void)contentViewConfirmEventWithParams:(NSDictionary *)params{

    //注册
    [[JGRequestHelper share]requestWithParams:params requestApi:[JGRegistApi class] hudMessage:@"注册中..." view:self.view successBlock:^(id result) {
        NSString *state=result[@"data"][@"state"];
        if ([state isEqualToString:@"11101"]) {
            JGpopViewController;
        }
    } faileBlock:nil];

//    _hud=[MBProgressHUD showMessage:@"注册中" ToView:self.view];
//    FQGetSignApi *signReq=[[FQGetSignApi alloc]initWithParams:params];
//    FQChainRequest *chainReq=[[FQChainRequest alloc]init];
//    [chainReq addRequest:signReq callback:^(YTKChainRequest * _Nonnull chainRequest, YTKBaseRequest * _Nonnull baseRequest) {
//        FQGetSignApi *req=(FQGetSignApi*)baseRequest;
//       JGRegistApi*registApi=[[JGRegistApi alloc]initWithSi:[req si] Pa:[req pa]];
//        [chainRequest addRequest:registApi callback:nil];
//    }];
//    chainReq.delegate=self;
//    [chainReq start];
}

-(void)contentViewChooseAddressEvent{

}

#pragma mark - override
-(UIColor *)lmjNavigationBackgroundColor:(LMJNavigationBar *)navigationBar{

    return [UIColor whiteColor];
}

-(BOOL)lmjNavigationIsHideBottomLine:(LMJNavigationBar *)navigationBar{
    return NO;
}

-(NSMutableAttributedString *)lmjNavigationBarTitle:(LMJNavigationBar *)navigationBar{

    return [NSMutableAttributedString changeTitle:@"注册" color:HEXCOLOR(0x404040)];
}

-(UIImage *)lmjNavigationBarLeftButtonImage:(UIButton *)leftButton navigationBar:(LMJNavigationBar *)navigationBar{
    return [UIImage imageNamed:@"signup_icon_return"];
}

- (UIStatusBarStyle)navUIBaseViewControllerPreferStatusBarStyle:(LMJNavUIBaseViewController *)navUIBaseViewController
{
    return UIStatusBarStyleDefault;
}
//#pragma mark api delegate
//-(void)chainRequestFinished:(YTKChainRequest *)chainRequest{
//   NSDictionary *dic= chainRequest.requestArray[1].responseJSONObject;
//    NSString *state=dic[@"data"][@"state"];
//    NSString *message=dic[@"data"][@"msg"];
//    _hud.label.text=message;
//    [_hud hideAnimated:YES afterDelay:0.5];
//    if ([state isEqualToString:@"11101"]) {
//        JGpopViewController;
//    }
//}
//
//-(void)chainRequestFailed:(YTKChainRequest *)chainRequest failedBaseRequest:(YTKBaseRequest *)request{
//
//    _hud.label.text=@"注册失败";
//    [_hud hideAnimated:YES afterDelay:0.5];
//}

#pragma mark - getters
-(JGRegistContentView *)contentView{
    if (_contentView==nil) {
        _contentView=[[JGRegistContentView alloc]initWithFrame:CGRectMake(0, self.lmj_navgationBar.height, JGScreenW, JGScreenH-self.lmj_navgationBar.height)];
        _contentView.delegate=self;
    }
    return _contentView;
}

@end
